//
//  LFAccountOrderDetailViewController.m
//  LoveFruit
//
//  Created by 刘栋 on 16/9/25.
//  Copyright © 2016年 张令林. All rights reserved.
//

#import "LFAccountOrderDetailViewController.h"

#define cellGoodsId @"cellGoodsId"

#define cellId @"cellId"
#import "LFOrderPriceViewCell.h"

@interface LFAccountOrderDetailViewController () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,weak) UITableView *tableView;

//数据源
@property (nonatomic,strong) NSMutableArray *dataArray;

@end

@implementation LFAccountOrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor redColor];
    
    self.navigationController.navigationBar.translucent = NO;
    
//    self.automaticallyAdjustsScrollViewInsets = NO;
    //订单详情
    [self createTableView];
    
    [self loadData];
}


- (void)loadData{
    NSArray *tempArr1 = @[@"订 单 号 a001z20160914",@"收 获 码 8220",@"下单时间 2016-09-25 14:44:22",@"送货时间 09月26日 10:00-20:00",@"配送方式 送货上门",@"支付方式 在线方式",@"备  注 无"];
    NSArray *tempArr2 = @[@"收 货 人 赵明",@"电  话 13729009417",@"收获地址 中腾建华商务大厦35"];
    [self.dataArray addObject:tempArr1];
    [self.dataArray addObject:tempArr2];
    
    [self.tableView reloadData];
}

- (NSMutableArray *)dataArray
{
   if(_dataArray == nil)
   {
       _dataArray = [NSMutableArray array];
   }
    return _dataArray;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section == 2)
    {
        return 240;
    }
    else
    {
        return 40;
    }
}

- (void)createTableView
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];
    
    self.tableView = tableView;
//    tableView.separatorStyle = 
    
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"LFOrderPriceViewCell" bundle:nil] forCellReuseIdentifier:cellGoodsId];
    
    tableView.showsVerticalScrollIndicator = NO;
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellId];
    
    //设置约束
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.equalTo(self.view);
        
    }];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(section == 0)
    {
        return 7;
    }
    else if (section == 1)
    {
        return 3;
    }else
    {
        return 1;
    }
}

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    [self tableView:tableView didDeselectRowAtIndexPath:indexPath];
//}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section != 2)
    {
        //static NSString *cellId = @"cellId";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId forIndexPath:indexPath];
        if(cell == nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId];
        }
        //cell.textLabel.text = [NSString stringWithFormat:@"下单时间  2016-09-24 23:34:05"];
        
        cell.textLabel.text = [NSString stringWithFormat:@"%@",self.dataArray[indexPath.section][indexPath.row]];
        
        cell.textLabel.font = [UIFont systemFontOfSize:15];
        
        //去掉点击效果
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
    }
    else
    {
//        static NSString *cellPriceId = @"cellPriceId";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellGoodsId forIndexPath:indexPath];
        if(cell == nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellGoodsId];
            
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        //acell.textLabel.text = @"配送费";
        return cell;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
